#include <iostream>
#include "AvlTree.h"
using namespace std;

#define random(x) rand() % (x)
#define TESTN 10

    // Test program
int main( )
{
    srand(time(NULL));
    AvlTree<int> t;
    int NUMS = 10;
    /*for (int k = 0; k < NUMS; k ++){
	    t.insert(k);
    };
    t.keyprint( 2, 8);
    t.keyprint( 11, 12);*/
    for (int i = 0; i < 6; i ++){
	    for (int n = 0; n < NUMS; n ++){
		    t.insert(n);
	    }
	    double sumTime = 0;
	    for (int x = 0; x < TESTN; x ++){
		    int a = random(NUMS);
		    int b = random(NUMS);
	    	    clock_t startTime, endTime;
        	    int k1 = a < b ? a : b;
		    int k2 = a >= b ? a : b;
		    startTime = clock();
		    t.keyprint( k1, k2);
		    endTime = clock();
                    double time =  (double)(endTime - startTime) * 1000 / CLOCKS_PER_SEC;
                    sumTime = sumTime + time;
        }
        double avgTime = sumTime / TESTN;
        cout << "n = " << NUMS << ":" <<  avgTime << "ms" << endl;
	NUMS = NUMS * 10;
    }
    return 0;
}

